using System;
using System.Data;
using PCSComUtils.Common;
using PCSComUtils.MasterSetup.DS;
using PCSComUtils.PCSExc;
using PCSComSale.Order.DS;

namespace PCSComSale.Order.BO
{
    public class SOAdditionChargesBO //: ISOAdditionChargesBO
    {
        private const string THIS = "PCSComSale.Order.BO.SOAdditionChargesBO";
        public SOAdditionChargesBO()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public void Add(object pObjectDetail)
        {
            // TODO:  Add SOAdditionChargesBO.Add implementation

        }

        public void Delete(object pObjectVO)
        {
            // TODO:  Add SOAdditionChargesBO.Delete implementation

        }

        public object GetObjectVO(int pintID, string VOclass)
        {
            // TODO:  Add SOAdditionChargesBO.GetObjectVO implementation
            return null;
        }

        public void Update(object pObjectDetail)
        {
            // TODO:  Add SOAdditionChargesBO.Update implementation

        }

        //**************************************************************************              
        ///    <Description>
        ///       This method uses to update a dataset
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       DataSet
        ///    </Outputs>
        ///    <Returns>
        ///       DataSet
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       17-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public void UpdateDataSet(DataSet dstData)
        {
            try
            {
                SO_AdditionChargeDS dsAddCharge = new SO_AdditionChargeDS();
                dsAddCharge.UpdateDataSet(dstData);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to update a dataset
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       DataSet
        ///    </Outputs>
        ///    <Returns>
        ///       DataSet
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       17-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public void UpdateDataSet(DataSet dstData, int pintSOMasterID)
        {
            try
            {
                SO_AdditionChargeDS dsAddCharge = new SO_AdditionChargeDS();
                dsAddCharge.UpdateDataSet(dstData, pintSOMasterID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get additional charge by SO Master
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       DataSet
        ///    </Outputs>
        ///    <Returns>
        ///       DataSet
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       17-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public DataSet GetAdditionalChargeBySOMasterID(int pintSOMasterID)
        {
            try
            {
                SO_AdditionChargeDS dsSOAddtionCharge = new SO_AdditionChargeDS();
                MST_ReasonDS dsReason = new MST_ReasonDS();
                DataSet dstData = dsSOAddtionCharge.GetAdditionalChargeBySOMasterID(pintSOMasterID);
                // fill reason code if have id
                foreach (DataRow drowData in dstData.Tables[0].Rows)
                {
                    if ((drowData[SO_AdditionChargeTable.REASONID_FLD] != null) && (drowData[SO_AdditionChargeTable.REASONID_FLD].ToString() != string.Empty)
                        && (drowData[SO_AdditionChargeTable.REASONID_FLD].ToString() != "0"))
                    {
                        string strReasonCode = dsReason.GetCodeFromID(int.Parse(drowData[SO_AdditionChargeTable.REASONID_FLD].ToString()));
                        if ((strReasonCode != null) && (strReasonCode != string.Empty))
                        {
                            drowData[MST_ReasonTable.TABLE_NAME + MST_ReasonTable.CODE_FLD] = strReasonCode;
                        }
                    }
                }
                return dstData;
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get data  by SO Master
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       DataSet
        ///    </Outputs>
        ///    <Returns>
        ///       DataSet
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       17-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public DataSet GetDataBySOMasterID(int pintSOMasterID)
        {
            try
            {
                SO_AdditionChargeDS dsSOAddtionCharge = new SO_AdditionChargeDS();
                return dsSOAddtionCharge.GetDataBySOMasterID(pintSOMasterID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get CCN Code from ID
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       string
        ///    </Outputs>
        ///    <Returns>
        ///       string
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       17-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public string GetCCNCodeFromID(int pintCCNID)
        {
            try
            {
                MST_CCNDS dsCCN = new MST_CCNDS();
                return dsCCN.GetCCNCodeFromID(pintCCNID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get SaleOderMaster value object from ID
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       SO_SaleOrderMasterVO
        ///    </Outputs>
        ///    <Returns>
        ///       SO_SaleOrderMasterVO
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       17-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public SO_SaleOrderMasterVO GetSaleOrderMasterVOFromID(int pintSaleOrderMasterID)
        {
            try
            {
                SO_SaleOrderMasterDS dsSaleOrderMaster = new SO_SaleOrderMasterDS();
                return (SO_SaleOrderMasterVO)(dsSaleOrderMaster.GetObjectVO(pintSaleOrderMasterID));
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }       
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to check UM of all products
        ///    </Description>
        ///    <Inputs>
        ///        Sale Order Master ID (int)
        ///    </Inputs>
        ///    <Outputs>
        ///       return true if all of product have same UM
        ///       else return false
        ///    </Outputs>
        ///    <Returns>
        ///       bool
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       18-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public bool IsChargeByQuantity(int pintSOMasterID)
        {
            try
            {
                SO_AdditionChargeDS dsAddCharge = new SO_AdditionChargeDS();
                return dsAddCharge.IsChargeByQuantity(pintSOMasterID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to check sale order master was charged or not
        ///    </Description>
        ///    <Inputs>
        ///        Sale Order Master ID (int)
        ///    </Inputs>
        ///    <Outputs>
        ///       return true if Master was charged
        ///       else return false
        ///    </Outputs>
        ///    <Returns>
        ///       bool
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       18-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public bool AlreadyCharged(int pintSOMasterID)
        {
            try
            {
                SO_AdditionChargeDS dsAddCharge = new SO_AdditionChargeDS();
                return dsAddCharge.AlreadyCharged(pintSOMasterID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get AddChargeVO
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       object
        ///    </Outputs>
        ///    <Returns>
        ///       
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       18-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public object GetAddCharge(int pintAddChargeID)
        {
            try
            {
                MST_AddChargeDS dsAddCharge = new MST_AddChargeDS();
                return dsAddCharge.GetObjectVO(pintAddChargeID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get ReasonVO
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       object
        ///    </Outputs>
        ///    <Returns>
        ///       
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       18-Feb-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public object GetReasonVO(int pintReasonID)
        {
            try
            {
                MST_ReasonDS dsReason = new MST_ReasonDS();
                return dsReason.GetObjectVO(pintReasonID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        //**************************************************************************              
        ///    <Description>
        ///       This method uses to get order quantity of a detail
        ///    </Description>
        ///    <Inputs>
        ///        int
        ///    </Inputs>
        ///    <Outputs>
        ///       decimal
        ///    </Outputs>
        ///    <Returns>
        ///       
        ///    </Returns>
        ///    <Authors>
        ///       DungLa
        ///    </Authors>
        ///    <History>
        ///       05-Apr-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************
        //[AutoComplete(true)]
        public decimal GetOrderQuantity(int pintSODetailID)
        {
            try
            {
                SO_SaleOrderDetailDS dsDetail = new SO_SaleOrderDetailDS();
                return dsDetail.GetOrderQuantity(pintSODetailID);
            }
            catch (PCSException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}
